//
//  KVCVC.m
//  kvo
//
//  Created by YuanJiang on 2019/9/5.
//  Copyright © 2019 llbt. All rights reserved.
//

#import "KVCVC.h"
#import "KVCModel.h"
#import "Person.h"
@interface KVCVC ()

@property(nonatomic,strong) KVCModel *model;

@end

@implementation KVCVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //eg1
    NSDictionary *dic = @{
                          @"age":@"23",
                          @"name":@"li",
                          @"sex":@"nan",
                          @"hobby":@"play",
                          @"height":@"110",
                          @"other":@"dd",
                          @"ddd":@"1"
                          };
    self.model = [[KVCModel alloc] initWithDic:dic];
    
    NSLog(@"self.model.name %@",self.model);
    
    
    //eg2
    Person *p = [[Person alloc] init];
    [p setValue:@"li" forKey:@"name"];
    
    //eg3
    Person *person = [[Person alloc] init];
    Phone *phone   = person.phone;
    Battery*battery= phone.barrery;
    //可以用以下代替
    Battery *bat   =[person valueForKeyPath:@"phone.battety"];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
